//
//  Status.swift
//  WKweiBo
//
//  Created by 阿拉斯加的狗 on 15/12/11.
//  Copyright © 2015年 阿拉斯加的🐶. All rights reserved.
//

import UIKit

class Status: NSObject {

    /// 微博ID
    var id: Int = 0
    /// 微博信息内容
    var text: String?
    /// 微博创建时间
    var created_at: String?
    /// 微博来源
    var source: String?
    /// 缩略图数组
    var pic_urls: [[String: String]]?
    /// 用户模型
    var user: User?
    /// 被转发的原微博信息字段
    var retweeted_status: Status?
    
    //kvc 构造函数
    init (dict: [String: AnyObject]) {
    
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
        
            if let dict = value as? [String: AnyObject] {
            
                user = User(dict: dict)
            
            }
        
                return
        }
        
        //转发微博模型
        if key == "retweeted_status" {
            
            if let dict = value as? [String: AnyObject] {
                
                retweeted_status = Status(dict: dict)
                
            }
            
            return
        }
        
            super.setValue(value, forKey: key)
        
    }
    
    
    override var description: String {
        let keys = ["id", "text", "created_at", "source","pic_urls","retweeted_status"]
        
        return dictionaryWithValuesForKeys(keys).description
    }
    
}
